package com.chenwy.example.controller;
import com.chenwy.example.entity.main.Slave;
import com.chenwy.example.service.SlaveService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2019/5/6.
 */
@RestController
@RequestMapping(value = "slave")
@Slf4j
public class SlaveController {

    @Autowired
    private SlaveService slaveService;

    @RequestMapping(value="slave/{id}",method = RequestMethod.GET)
    public Slave get(@PathVariable(value = "id") Long id){
        return slaveService.get(id);
    }

    @RequestMapping(value="slave",method = RequestMethod.PUT)
    @ApiOperation("保存slave对象")
    public Slave save(@ApiParam(name="slave对象",required = true) @RequestBody Slave slave){
        try{
            slaveService.save(slave);
        }catch(Exception e){

        }
        return slave;
    }

    @RequestMapping(value="slave1",method = RequestMethod.PUT)
    public Slave save1(Slave slave){
        try{
//            slaveService.save1(slave);
        }catch(Exception e){

        }
        return slave;
    }
}
